//
//  AddInforView.m
//  IceBoxStrorage
//
//  Created by xieyanhong on 2023/8/22.
//

#import "AddInforView.h"

@implementation AddInforView

-(instancetype)init{
    if (self = [super initWithFrame:CGRectZero]) {
        [self initSubView];
    }
    
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}

- (void)deviceSelectAction:(UIButton *)butoon{
    if(self.InforBack){
        self.InforBack(butoon);
    }
    
}

-(void)setNameStr:(NSString *)nameStr{
    _nameStr = nameStr;
    self.nameLabel.text = nameStr;
    [self.contentBtn setTitle:[NSString stringWithFormat:@"place select %@ >>",nameStr] forState:0];
}

- (void)initSubView{
    
    UIView *baseView = [[UIView alloc]init];
    [self addSubview:baseView];
    [baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).insets(UIEdgeInsetsMake(8, 8, 8, 8));
    }];
    baseView.backgroundColor = rgba(245, 245, 245, 1);
    baseView.layer.cornerRadius = 4;
    baseView.layer.masksToBounds = YES;
    
    UILabel *titleLabel = [[UILabel alloc]init];
    [baseView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(baseView.mas_centerY);
        make.left.equalTo(@16);
    }];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.font = [UIFont boldSystemFontOfSize:16];
    titleLabel.textColor = UIColor.blackColor;
    self.nameLabel = titleLabel;
    
    
    UIButton *deviceButton = [[UIButton alloc]init];
    [baseView addSubview:deviceButton];
    [deviceButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(baseView.mas_centerY);
        make.right.equalTo(@-16);
        make.left.equalTo(titleLabel.mas_right).offset(8);
        make.height.mas_equalTo(30);
    }];
    [deviceButton setTitleColor:[UIColor blackColor] forState:0];
    deviceButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [deviceButton addTarget:self action:@selector(deviceSelectAction:) forControlEvents:UIControlEventTouchUpInside];
    self.contentBtn = deviceButton;
    
    
    
}

@end
